package main

import (
	"embed"
	"tencent-video-desktop/backend/internal/api"
	"tencent-video-desktop/backend/internal/services"

	"github.com/wailsapp/wails/v2"
	"github.com/wailsapp/wails/v2/pkg/options"
	"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)

//go:embed all:frontend/dist
var assets embed.FS

func main() {
	// Create an instance of the app structure
	app := NewApp()

	// Create services
	videoService := services.NewVideoService()
	fileService := services.NewFileService()

	// Create API handlers
	videoHandler := api.NewVideoHandler(videoService)
	fileHandler := api.NewFileHandler(fileService)

	// Create application with options
	err := wails.Run(&options.App{
		Title:  "腾讯视频桌面版",
		Width:  1200,
		Height: 800,
		AssetServer: &assetserver.Options{
			Assets: assets,
		},
		BackgroundColour: &options.RGBA{R: 10, G: 10, B: 10, A: 255},
		OnStartup:        app.startup,
		OnDomReady:       app.domReady,
		OnBeforeClose:    app.beforeClose,
		OnShutdown:       app.shutdown,
		Bind: []interface{}{
			app,
			videoHandler,
			fileHandler,
		},
	})

	if err != nil {
		println("Error:", err.Error())
	}
}
